<template>
  <el-input
    v-model="value"
    placeholder=""
  >
  </el-input>
</template>

<script>
  import {computed, useSlots, useAttrs} from 'vue'
  import { ElInput } from 'element-plus'

</script>

<script setup>

  // 设置属性
  const props = defineProps({
    modelValue: [String, Number, Object],
    model: Object,
    colName: String
  })

  const emit = defineEmits(['update:modelValue'])
  
  console.log('props：', props)
  console.log('emit：', emit)

  const value = computed({
    set: (val) => {
      if (typeof props.model === 'object') {
        console.time('proxy')
        props.model[props.colName] = val
        console.timeEnd('proxy')
      } else {
        console.time('emit')
        emit('update:modelValue', val)
        console.timeEnd('emit')
      }
    },
    get: () => {
      if (typeof props.model === 'object')
        return props.model[props.colName]
      else
        return props.modelValue
    }
  })

</script>